﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AzureGames.Data;
using AzureGames.Domain.Contracts;
using AzureGames.Domain.Models;

namespace AzureGames.Domain.Handlers
{
    public class UpdateResource
    {
        private readonly IResourceRepository _resourceRepository;

        public UpdateResource(IResourceRepository resourceRepository)
        {
            _resourceRepository = resourceRepository;
        }

        public virtual void Execute(Model.Resource resource)
        {
            try
            {
                _resourceRepository.UpdateResource(resource);

                
            }
            catch (InvalidOperationException e)
            {
                throw new BusinessServicesException("Unable to update game resource to database.", e);
            }
        }
    }
}